local CommonOHOH = _G.CommonOHOH;
local M = CommonOHOH.class.new(script, CommonOHOH.files.BaseComponent());

--概述：控制怪物的动画播放
local broGui=_G.ClientOHOH.load.UIManager().ui_list.BroGui

----------
function M.new(self,...)
	return M(self,...);
end;

function M.ctor(self, parent)
	M.super.ctor(self, parent);

    self.player=self.parent.player
	self.character=self.parent

    local animationIdList={
        run= broGui:GetRunAnimation().AnimationId,
        upgrade=broGui:GetUpgradeAnimation().AnimationId
    }

    local loop={
        run=true,
        upgrade=false,
    }



   
    self.character:GetShowState("show").EnterEvent:Connect(function()
        self.Animatior=self.parent:AddComponent(_G.CommonOHOH.load.CharacterAnimationCtrl()); 
        if not  self.isLoadAnimation then
            self.Animatior:PreLoadAnimationByRid(animationIdList,nil,nil,loop); 
            self.isLoadAnimation=true
        end
       
       self.ShowCon= self:AddProcess(function()
            local t=self.Animatior:PlayAnimation("upgrade")
            t=t or 0
            self:Wait(t+0.5)
            self.Animatior:PlayAnimation("run")
        end)
       
    end)

    self.character:GetShowState("hide").EnterEvent:Connect(function()
        if  self.ShowCon then
            self.ShowCon:Disconnect()
            self.ShowCon=nil
        end
        if  self.Animatior then
            self.Animatior:StopAnimation("run")
        end
    end)

	self.character:GetState("upgrade").EnterEvent:Connect(function()
        if   self.Animatior then
            self.Animatior:PlayAnimation("upgrade")
        end
	end)

end;




function M.dtor(self)
	M.super.dtor(self);
end



return M